package pkg

import (
	"encoding/json"
	"github.com/Baidu-AIP/golang-sdk/aip/censor"
	"good/config"
)

type ConclusionStatus struct {
	ConclusionType uint `json:"conclusionType"`
}

func BaiDU(str string) bool {
	AppConf := config.AppConf.BaiDu
	client := censor.NewClient(AppConf.ApiKey, AppConf.SecretKey)
	res := client.TextCensor(str)

	var data ConclusionStatus
	_ = json.Unmarshal([]byte(res), &data)
	if data.ConclusionType != 1 {
		return false
	}
	return true
}
